package cn.itbox.example.test.controller;

import cn.itbox.uap.util.http.OkHttpExtUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @CreateTime: 2024-02-21  10:17
 * @Version: 1.0
 * @Author: huyanbing
 */
@Slf4j
@RestController
@RequestMapping("/ok/https")
public class OkHtttpsTestController {


    @Resource
    private OkHttpExtUtil okHttpExtUtil;


    @GetMapping
    public String list() {

        String url = "https://sandbox.99bill.com:7445/umgw/common/distribute.html";
        String body = "{\"head\":{\"memberCode\":\"10012932671\",\"messageType\":\"M0001\",\"version\":\"1.0.0\",\"externalRefNumber\":\"20240221101149_0b19e\"},\"requestBody\":{\"signedData\":\"a3caa15e-26a5-4a90-829b-6e4596f79f07\",\"envelopedData\":\"92280ee7-460e-4e71-a295-b659092f0e57\"}}";
        Map<String, String> headers = new HashMap<>();
        headers.put("okhttp-test", "1");
        String res = okHttpExtUtil.post(url, body, headers, 1000L);

        System.out.printf(res);

        return res;
    }
}
